Analazing the impact of Satisfaction with financial situation of household effect Feeling of happiness¶

Introduction:¶

Happiness is a fundamental aspect of human well-being, and understanding the factors that influence it has long been a subject of study. Among these factors, financial satisfaction plays a significant role, as it impacts an individual’s ability to meet their needs and pursue personal goals. This project explores the relationship between satisfaction with one’s financial situation and feelings of happiness. By analyzing survey data, this study aims to uncover patterns and insights that highlight the importance of financial well-being in shaping happiness.

Project Overview¶

This project aims to analyze the relationship between household satisfaction with their financial situation and their feelings of happiness. Using a dataset derived from Moroccan households, the study applies various data manipulation, visualization, and geospatial analysis techniques to uncover trends and patterns.

Key questions addressed include:

  • Does financial satisfaction significantly influence happiness?
  • Are there differences in the relationship between financial satisfaction and happiness in different regions of Morocco?

(Dependent variable is Y = feelings of happiness, Independent variable X = atisfaction with financial situation of household)

Methodology¶

The study employs a structured approach, using Python for data manipulation, statistical analysis, and visualization. The methodology includes:

  1. Data Preparation: Cleaning and preprocessing the Moroccan dataset to ensure consistency and completeness.
  2. Exploratory Data Analysis (EDA): Generating descriptive statistics and visualizations to summarize the dataset and identify initial trends.
  3. Correlation and Regression Analysis: Examining the statistical relationship between financial satisfaction and happiness.
  4. Geospatial Analysis: Utilizing GeoPandas to map regional variations in the findings.
  5. Data Visualization: Leveraging Seaborn, Matplotlib, and Plotly for clear and interactive data presentation.

Key Steps¶

  1. Data Loading and Cleaning:

    • Load and view the dataset using pandas, pyreadstat and Data Wrangler (vscode extension).
    • Handle missing or inconsistent values to prepare for analysis.
  2. Exploratory Data Analysis (EDA):

    • Use pandas, numpy and statsmodels for descriptive statistics.
    • Visualize data distributions and relationships using matplotlib, seaborn plotly.
  3. Correlation and Statistical Modeling:

    • Compute correlation coefficients between financial satisfaction and happiness.
    • Build regression models to quantify the relationship.
  4. Geospatial Analysis:

    • Use geopandas to integrate geographic data.
    • Create visualizations that highlight regional differences across Morocco.
  5. Data Visualization and Insights:

    • Design static and interactive plots using Plotly to present results.
    • Interpret the findings in the context of Morocco’s socioeconomic landscape.

In [88]:
# Libraries used
#Manipulation/Calucaltion
import pandas as pd
import pyreadstat 
import numpy as np
from statsmodels.miscmodels.ordinal_model import OrderedModel
#plotting
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
from plotly.subplots import make_subplots
import plotly.io as pio
pio.renderers.default = "notebook"

#goefileloade/read
import geopandas as gpd
import json
# pandast option setup
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', 15)
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
In [89]:
# Loading the main dataset: df 
df, meta = pyreadstat.read_sav('Project_Dataset.sav')
In [90]:
df
Out[90]:
version doi A_YEAR B_COUNTRY B_COUNTRY_ALPHA C_COW_NUM C_COW_ALPHA D_INTERVIEW J_INTDATE FW_START FW_END K_TIME_START K_TIME_END K_DURATION Q_MODE N_REGION_ISO N_REGION_WVS N_TOWN G_TOWNSIZE G_TOWNSIZE2 H_SETTLEMENT H_URBRURAL I_PSU O1_LONGITUDE O2_LATITUDE S_INTLANGUAGE LNGE_ISO E_RESPINT F_INTPRIVACY W_WEIGHT S018 PWGHT Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 Q13 Q14 Q15 Q16 Q17 Q18 Q19 Q20 Q21 Q22 Q23 Q24 Q25 Q26 Q27 Q28 Q29 Q30 Q31 Q32 Q33 Q33_3 Q34 Q34_3 Q35 Q35_3 Q37 Q38 Q39 Q40 Q41 Q42 Q43 Q44 Q45 Q46 Q47 Q48 Q49 Q50 Q51 Q52 Q53 Q54 Q55 Q56 Q57 Q58 Q59 Q60 Q61 Q62 Q63 Q64 Q65 Q66 Q67 Q68 Q69 Q70 Q71 Q72 Q73 Q74 Q75 Q76 Q77 Q78 Q79 Q80 Q81 Q82 Q82_ARABLEAGUE Q82_GULFCOOP Q82_ISLCOOP Q83 Q84 Q85 Q86 Q87 Q88 Q89 Q90 Q91 Q92 Q93 Q94 Q95 Q96 Q97 Q98 Q99 Q100 Q101 Q102 Q103 Q104 Q105 Q106 Q107 Q108 Q109 Q110 Q111 Q112 Q113 Q114 Q115 Q116 Q117 Q118 Q119 Q120 Q121 Q122 Q123 Q124 Q125 Q126 Q127 Q128 Q129 Q130 Q131 Q132 Q133 Q134 Q135 Q136 Q137 Q138 Q139 Q140 Q141 Q142 Q143 Q144 Q145 Q146 Q147 Q148 Q149 Q150 Q151 Q152 Q153 Q154 Q155 Q156 Q157 Q158 Q159 Q160 Q161 Q162 Q163 Q164 Q165 Q166 Q167 Q168 Q169 Q170 Q171 Q172 Q173 Q174 Q175 Q176 Q177 Q178 Q179 Q180 Q181 Q182 Q183 Q184 Q185 Q186 Q187 Q188 Q189 Q190 Q191 Q192 Q193 Q194 Q195 Q196 Q197 Q198 Q199 Q200 Q201 Q202 Q203 Q204 Q205 Q206 Q207 Q208 Q209 Q210 Q211 Q212 Q213 Q214 Q215 Q216 Q217 Q218 Q219 Q220 Q221 Q222 Q223 Q223_ABREV Q223_LOCAL Q224 Q225 Q226 Q227 Q228 Q229 Q230 Q231 Q232 Q233 Q234 Q234A Q235 Q236 Q237 Q238 Q239 Q240 Q241 Q242 Q243 Q244 Q245 Q246 Q247 Q248 Q249 Q250 Q251 Q252 Q253 Q254 Q255 Q256 Q257 Q258 Q259 Q260 Q261 Q262 X003R X003R2 Q263 Q264 Q265 Q266 Q267 Q268 Q269 Q270 Q271 Q272 Q273 Q274 Q275 Q275R Q276 Q276R Q277 Q277R Q278 Q278R Q279 Q280 Q281 Q282 Q283 Q284 Q285 Q286 Q287 Q288 Q288R Q289 Q289CS9 Q290 Q291G1 Q291G2 Q291G3 Q291G4 Q291G5 Q291G6 Q291P1 Q291P2 Q291P3 Q291P4 Q291P5 Q291P6 Q291UN1 Q291UN2 Q291UN3 Q291UN4 Q291UN5 Q291UN6 Q292A Q292B Q292C Q292D Q292E Q292F Q292G Q292H Q292I Q292J Q292K Q292L Q292M Q292N Q292O Q293 Q294A Q294B Y001 Y002 Y003 SACSECVAL SACSECVALB RESEMAVAL RESEMAVALB I_AUTHORITY I_NATIONALISM I_DEVOUT DEFIANCE I_RELIGIMP I_RELIGBEL I_RELIGPRAC DISBELIEF I_NORM1 I_NORM2 I_NORM3 RELATIVISM I_TRUSTARMY I_TRUSTPOLICE I_TRUSTCOURTS SCEPTICISM I_INDEP I_IMAGIN I_NONOBED AUTONOMY I_WOMJOB I_WOMPOL I_WOMEDU EQUALITY I_HOMOLIB I_ABORTLIB I_DIVORLIB CHOICE I_VOICE1 I_VOICE2 I_VOI2_00 VOICE SECVALWGT WEIGHT1A WEIGHT1B WEIGHT2A WEIGHT2B WEIGHT3A WEIGHT3B WEIGHT4A WEIGHT4B RESEMAVALBWGT RESEMAVALWGT SECVALBWGT Y001_1 Y001_2 Y001_3 Y001_4 Y001_5
0 0.0 0.0 2021.0 504.0 MAR 600.0 MOR 504070001.0 20211112.0 202111.0 202112.0 10.05 10.43 38.0 2.0 504009.0 504019.0 504099.0 1.0 1.0 4.0 2.0 99.0 -8.84 29.49 170.0 ar 1.0 2.0 1.0 0.833333 31083.33333 1.0 2.0 1.0 1.0 1.0 1.0 1.0 2.0 1.0 1.0 2.0 2.0 2.0 2.0 1.0 2.0 1.0 1.0 2.0 2.0 1.0 1.0 1.0 2.0 1.0 2.0 1.0 2.0 1.0 3.0 1.0 1.0 2.0 1.0 1.0 1.0 1.0 1.0 2.0 1.0 1.0 1.0 3.0 2.0 2.0 1.0 3.0 2.0 3.0 5.0 8.0 6.0 4.0 3.0 4.0 4.0 4.0 3.0 2.0 1.0 3.0 2.0 4.0 4.0 2.0 2.0 3.0 3.0 2.0 3.0 3.0 1.0 4.0 4.0 4.0 3.0 2.0 1.0 1.0 3.0 1.0 2.0 3.0 2.0 2.0 2.0 2.0 2.0 3.0 2.0 3.0 4.0 4.0 2.0 5.0 3.0 3.0 2.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 6.0 4.0 5.0 5.0 5.0 2.0 10.0 3.0 3.0 2.0 2.0 3.0 3.0 3.0 8.0 3.0 2.0 2.0 1.0 2.0 1.0 2.0 1.0 0.0 3.0 2.0 3.0 3.0 2.0 2.0 3.0 3.0 3.0 1.0 2.0 1.0 2.0 2.0 2.0 2.0 1.0 1.0 2.0 2.0 2.0 2.0 1.0 3.0 1.0 4.0 2.0 4.0 6.0 8.0 8.0 5.0 6.0 8.0 10.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 2.0 2.0 1.0 4.0 5.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 7.0 2.0 1.0 6.0 2.0 8.0 1.0 1.0 1.0 3.0 10.0 1.0 4.0 4.0 2.0 3.0 5.0 1.0 2.0 2.0 4.0 2.0 2.0 5.0 1.0 1.0 3.0 3.0 2.0 3.0 2.0 3.0 2.0 3.0 3.0 3.0 2.0 2.0 504011.0 504011.0 504011.0 1.0 3.0 2.0 1.0 1.0 1.0 1.0 4.0 4.0 3.0 2.0 5.0 4.0 4.0 4.0 2.0 1.0 8.0 10.0 7.0 6.0 9.0 4.0 8.0 9.0 5.0 10.0 10.0 3.0 1.0 3.0 3.0 4.0 4.0 4.0 3.0 4.0 2.0 1969.0 52.0 4.0 3.0 1.0 1.0 1.0 504.0 504.0 504.0 1.0 8.0 1.0 500.0 1.0 4.0 1.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 1.0 5.0 5.0 9.0 9.0 2.0 1.0 3.0 2.0 6.0 2.0 5.0 50000000.0 504005.0 5.0 2.0 5.0 4.0 5.0 5.0 5.0 2.0 5.0 4.0 5.0 4.0 3.0 4.0 4.0 2.0 5.0 3.0 5.0 4.0 3.0 2.0 2.0 4.0 2.0 2.0 1.0 1.0 1.0 5.0 4.0 1.0 3.0 1.0 1.0 1.0 3.0 2.0 -2.0 0.331667 0.443333 0.235139 0.262778 1.0 0.66 0.00 0.553333 0.00 1.0 0.000000 0.333333 0.0 0.0 0.0 0.000000 0.66 0.66 0.00 0.440000 0.0 0.0 0.0 0.000000 0.25 0.00 0.66 0.303333 0.000000 0.000000 0.666667 0.222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 6.0 1.0 4.0 4.0 2.0 2.0 4.0 4.0 5.0 1.0 5.0 1.0 1.0 4.0 2.0 1.0 2.0 2.0 1.0 2.0 2.0 3.0 2.0 2.0 3.0 3.0 3.0 3.0 504009.0 504009.0 504009.0 4.0 3.0 4.0 4.0 4.0 4.0 1.0 1.0 3.0 2.0 1.0 5.0 1.0 1.0 4.0 1.0 1.0 1.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 10.0 5.0 8.0 6.0 7.0 3.0 1.0 1.0 1.0 2.0 3.0 4.0 2.0 1998.0 23.0 1.0 1.0 1.0 1.0 1.0 504.0 504.0 504.0 1.0 6.0 2.0 500.0 6.0 0.0 6.0 3.0 3.0 2.0 0.0 1.0 0.0 1.0 1.0 NaN 4.0 NaN 6.0 3.0 2.0 2.0 4.0 7.0 2.0 5.0 50000000.0 504005.0 5.0 1.0 5.0 5.0 5.0 5.0 1.0 1.0 1.0 5.0 5.0 5.0 1.0 5.0 3.0 3.0 3.0 2.0 5.0 5.0 1.0 1.0 5.0 4.0 2.0 1.0 1.0 1.0 1.0 1.0 5.0 1.0 1.0 0.0 NaN NaN 2.0 1.0 -1.0 0.360556 0.111111 0.360556 0.387778 0.0 0.00 0.00 0.000000 0.00 0.0 0.666667 0.222222 1.0 1.0 1.0 1.000000 0.00 0.00 0.66 0.220000 0.0 1.0 1.0 0.666667 0.00 0.00 0.66 0.220000 0.444444 0.444444 0.777778 0.555556 0.00 0.0 0.000 0.000 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 1.0 1.0
2 0.0 0.0 2021.0 504.0 MAR 600.0 MOR 504070003.0 20211112.0 202111.0 202112.0 11.28 12.09 41.0 2.0 504009.0 504019.0 504099.0 1.0 1.0 4.0 2.0 99.0 -8.84 29.49 170.0 ar 1.0 2.0 1.0 0.833333 31083.33333 1.0 2.0 1.0 4.0 1.0 1.0 1.0 2.0 1.0 1.0 2.0 1.0 2.0 1.0 1.0 2.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.0 1.0 1.0 1.0 504.0 504.0 504.0 1.0 4.0 2.0 170.0 3.0 1.0 6.0 3.0 4.0 2.0 6.0 3.0 6.0 3.0 7.0 NaN 9.0 9.0 9.0 3.0 1.0 2.0 2.0 7.0 2.0 5.0 50000000.0 504005.0 5.0 4.0 1.0 4.0 4.0 1.0 5.0 5.0 2.0 4.0 4.0 2.0 2.0 3.0 2.0 3.0 2.0 1.0 5.0 5.0 3.0 2.0 4.0 5.0 1.0 3.0 5.0 4.0 1.0 4.0 4.0 4.0 2.0 7.0 NaN NaN 3.0 2.0 0.0 0.291389 0.249444 0.304583 0.360000 0.0 0.33 0.00 0.110000 0.00 1.0 0.166667 0.388889 1.0 1.0 0.0 0.666667 0.00 0.00 0.00 0.000000 0.0 0.0 1.0 0.333333 0.50 0.00 0.66 0.386667 0.000000 0.333333 0.666667 0.333333 0.33 0.0 0.165 0.165 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 1.0 1.0
3 0.0 0.0 2021.0 504.0 MAR 600.0 MOR 504070004.0 20211112.0 202111.0 202112.0 12.08 12.42 34.0 2.0 504009.0 504019.0 504099.0 1.0 1.0 4.0 2.0 99.0 -8.84 29.49 170.0 ar 1.0 1.0 1.0 0.833333 31083.33333 1.0 1.0 4.0 2.0 1.0 1.0 1.0 2.0 1.0 2.0 2.0 1.0 2.0 2.0 2.0 1.0 1.0 2.0 2.0 2.0 2.0 1.0 2.0 2.0 2.0 2.0 1.0 1.0 1.0 3.0 3.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 3.0 3.0 1.0 1.0 2.0 1.0 8.0 1.0 6.0 4.0 3.0 4.0 4.0 4.0 3.0 2.0 1.0 3.0 3.0 4.0 3.0 3.0 3.0 1.0 4.0 4.0 4.0 1.0 1.0 3.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 3.0 3.0 3.0 3.0 3.0 4.0 4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.0 0.000000 0.000000 0.055000 0.110000 0.0 0.00 0.00 0.000000 0.00 0.0 0.000000 0.000000 0.0 0.0 0.0 0.000000 0.00 0.00 0.00 0.000000 0.0 0.0 0.0 0.000000 0.00 0.00 0.66 0.220000 0.000000 0.000000 0.000000 0.000000 0.00 0.0 0.000 0.000 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 1.0
4 0.0 0.0 2021.0 504.0 MAR 600.0 MOR 504070005.0 20211112.0 202111.0 202112.0 13.18 13.55 37.0 2.0 504009.0 504019.0 504099.0 1.0 1.0 4.0 2.0 99.0 -8.84 29.49 170.0 ar 1.0 1.0 1.0 0.833333 31083.33333 1.0 2.0 3.0 3.0 1.0 1.0 1.0 1.0 2.0 1.0 2.0 2.0 2.0 1.0 2.0 1.0 2.0 1.0 2.0 1.0 2.0 1.0 2.0 1.0 2.0 2.0 1.0 1.0 3.0 3.0 2.0 1.0 1.0 1.0 1.0 1.0 3.0 3.0 3.0 2.0 4.0 4.0 3.0 1.0 3.0 2.0 2.0 3.0 2.0 7.0 7.0 4.0 2.0 3.0 2.0 4.0 4.0 3.0 2.0 1.0 3.0 2.0 3.0 3.0 3.0 2.0 2.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 4.0 3.0 4.0 4.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 5.0 2.0 1.0 3.0 1.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 6.0 5.0 3.0 1.0 5.0 1.0 8.0 3.0 3.0 3.0 3.0 3.0 3.0 4.0 10.0 3.0 2.0 1.0 1.0 1.0 0.0 2.0 0.0 1.0 2.0 1.0 2.0 2.0 4.0 2.0 2.0 2.0 1.0 1.0 2.0 2.0 2.0 1.0 2.0 2.0 1.0 1.0 1.0 2.0 2.0 2.0 1.0 2.0 1.0 3.0 1.0 2.0 8.0 10.0 7.0 6.0 1.0 8.0 10.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 2.0 1.0 1.0 7.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 3.0 1.0 4.0 1.0 8.0 2.0 1.0 4.0 5.0 10.0 1.0 4.0 4.0 4.0 3.0 5.0 5.0 5.0 5.0 5.0 1.0 1.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 2.0 3.0 3.0 3.0 3.0 3.0 4.0 4.0 4.0 1.0 2.0 4.0 2.0 2.0 1.0 2.0 3.0 2.0 1.0 3.0 4.0 4.0 3.0 4.0 1.0 1.0 7.0 1.0 3.0 5.0 9.0 6.0 10.0 10.0 3.0 9.0 8.0 5.0 3.0 3.0 3.0 2.0 2.0 3.0 3.0 4.0 1.0 1999.0 22.0 1.0 1.0 1.0 1.0 1.0 504.0 504.0 504.0 1.0 5.0 1.0 170.0 6.0 0.0 1.0 1.0 NaN NaN 3.0 2.0 2.0 1.0 1.0 NaN 5.0 NaN 9.0 3.0 2.0 3.0 4.0 7.0 2.0 5.0 50000000.0 504005.0 2.0 4.0 1.0 1.0 4.0 5.0 4.0 4.0 2.0 2.0 4.0 2.0 4.0 4.0 1.0 4.0 4.0 4.0 5.0 5.0 2.0 2.0 4.0 5.0 1.0 1.0 5.0 5.0 1.0 5.0 5.0 4.0 5.0 2.0 1.0 1.0 1.0 1.0 2.0 0.317500 0.360000 0.276667 0.220000 0.5 0.66 0.00 0.386667 0.00 1.0 0.000000 0.333333 0.0 0.0 0.0 0.000000 0.33 0.66 0.66 0.550000 1.0 0.0 1.0 0.666667 0.00 0.66 0.66 0.440000 0.000000 0.000000 0.000000 0.000000 0.00 0.0 0.000 0.000 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 1.0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
1195 0.0 0.0 2021.0 504.0 MAR 600.0 MOR 504071196.0 20211213.0 202111.0 202112.0 14.12 15.11 59.0 2.0 504002.0 504012.0 504081.0 5.0 3.0 3.0 1.0 81.0 -2.73 34.94 170.0 ar 1.0 1.0 1.0 0.833333 31083.33333 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 2.0 2.0 2.0 1.0 2.0 2.0 2.0 1.0 2.0 2.0 2.0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 504.0 504.0 1.0 5.0 1.0 170.0 6.0 0.0 4.0 2.0 NaN NaN 1.0 1.0 1.0 1.0 1.0 NaN 1.0 NaN 6.0 2.0 1.0 2.0 3.0 6.0 2.0 5.0 50000000.0 504005.0 2.0 4.0 4.0 1.0 4.0 2.0 2.0 5.0 2.0 2.0 4.0 2.0 2.0 4.0 4.0 2.0 2.0 2.0 2.0 2.0 4.0 4.0 2.0 2.0 4.0 4.0 2.0 2.0 4.0 2.0 2.0 4.0 4.0 5.0 4.0 4.0 5.0 3.0 2.0 0.526667 0.388333 0.628796 0.424259 0.0 0.33 0.00 0.110000 0.00 1.0 1.000000 0.666667 1.0 1.0 1.0 1.000000 0.33 0.33 0.33 0.330000 1.0 0.0 1.0 0.666667 0.00 0.33 0.66 0.330000 0.444444 0.555556 0.555556 0.518519 1.00 1.0 1.000 1.000 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1196 0.0 0.0 2021.0 504.0 MAR 600.0 MOR 504071197.0 20211213.0 202111.0 202112.0 15.30 16.25 55.0 2.0 504002.0 504012.0 504081.0 5.0 3.0 3.0 1.0 81.0 -2.73 34.94 170.0 ar 2.0 1.0 1.0 0.833333 31083.33333 2.0 2.0 2.0 4.0 2.0 2.0 2.0 1.0 1.0 2.0 2.0 2.0 1.0 1.0 2.0 2.0 1.0 1.0 2.0 2.0 2.0 1.0 2.0 1.0 2.0 2.0 2.0 2.0 3.0 3.0 3.0 3.0 3.0 3.0 1.0 1.0 4.0 2.0 2.0 1.0 1.0 2.0 4.0 1.0 3.0 1.0 3.0 2.0 3.0 7.0 6.0 6.0 3.0 3.0 3.0 2.0 3.0 3.0 2.0 4.0 4.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 4.0 4.0 4.0 4.0 4.0 4.0 3.0 3.0 4.0 3.0 3.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.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.581111 1.0 0.00 0.33 0.443333 0.33 1.0 1.000000 0.776667 1.0 1.0 1.0 1.000000 0.66 1.00 1.00 0.886667 1.0 0.0 0.0 0.333333 0.50 0.66 0.66 0.606667 0.333333 0.777778 0.555556 0.555556 0.66 0.5 0.580 0.580 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 1.0 0.0
1197 0.0 0.0 2021.0 504.0 MAR 600.0 MOR 504071198.0 20211213.0 202111.0 202112.0 16.02 17.10 68.0 2.0 504002.0 504012.0 504081.0 5.0 3.0 3.0 1.0 81.0 -2.73 34.94 170.0 ar 1.0 1.0 1.0 0.833333 31083.33333 1.0 4.0 2.0 4.0 2.0 1.0 1.0 2.0 2.0 1.0 2.0 2.0 1.0 2.0 1.0 2.0 1.0 1.0 2.0 2.0 1.0 1.0 2.0 1.0 1.0 2.0 1.0 1.0 3.0 4.0 3.0 2.0 2.0 1.0 2.0 1.0 2.0 1.0 4.0 2.0 2.0 4.0 4.0 1.0 3.0 3.0 1.0 2.0 3.0 6.0 10.0 3.0 4.0 4.0 2.0 2.0 4.0 1.0 1.0 1.0 1.0 1.0 2.0 3.0 3.0 1.0 1.0 3.0 2.0 4.0 2.0 2.0 3.0 3.0 3.0 2.0 2.0 3.0 3.0 3.0 3.0 3.0 4.0 3.0 3.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 1.0 2.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 4.0 8.0 5.0 5.0 9.0 1.0 7.0 3.0 3.0 3.0 3.0 3.0 3.0 2.0 9.0 1.0 2.0 0.0 2.0 0.0 0.0 0.0 2.0 2.0 4.0 2.0 4.0 4.0 4.0 4.0 4.0 4.0 4.0 1.0 1.0 2.0 4.0 3.0 2.0 2.0 1.0 1.0 1.0 2.0 2.0 1.0 1.0 4.0 1.0 3.0 1.0 4.0 5.0 5.0 5.0 7.0 7.0 5.0 10.0 1.0 1.0 1.0 1.0 1.0 1.0 7.0 1.0 1.0 2.0 2.0 6.0 9.0 6.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 9.0 5.0 5.0 5.0 5.0 7.0 4.0 3.0 3.0 4.0 3.0 5.0 1.0 5.0 5.0 5.0 5.0 5.0 5.0 3.0 3.0 3.0 3.0 2.0 2.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 4.0 4.0 4.0 4.0 3.0 1.0 1.0 4.0 4.0 1.0 1.0 4.0 3.0 1.0 5.0 2.0 2.0 4.0 3.0 2.0 1.0 10.0 8.0 4.0 10.0 4.0 4.0 4.0 4.0 10.0 4.0 5.0 5.0 4.0 1.0 1.0 1.0 1.0 1.0 1.0 2.0 1957.0 64.0 5.0 3.0 1.0 1.0 1.0 504.0 504.0 504.0 1.0 6.0 1.0 170.0 1.0 4.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 5.0 4.0 0.0 3.0 4.0 2.0 2.0 2.0 3.0 1.0 1.0 5.0 50000000.0 504005.0 4.0 2.0 2.0 2.0 4.0 4.0 2.0 2.0 2.0 2.0 4.0 2.0 4.0 2.0 2.0 4.0 4.0 4.0 4.0 2.0 2.0 2.0 4.0 4.0 2.0 4.0 4.0 4.0 2.0 4.0 4.0 2.0 2.0 4.0 NaN NaN 0.0 1.0 -2.0 0.388333 0.166667 0.270278 0.540556 0.0 0.00 0.00 0.000000 0.00 0.0 1.000000 0.333333 1.0 1.0 1.0 1.000000 0.00 0.33 0.33 0.220000 0.0 0.0 0.0 0.000000 0.25 0.66 1.00 0.636667 0.444444 0.444444 0.444444 0.444444 0.00 0.0 0.000 0.000 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0
1198 0.0 0.0 2021.0 504.0 MAR 600.0 MOR 504071199.0 20211213.0 202111.0 202112.0 17.10 18.02 52.0 2.0 504002.0 504012.0 504081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0 5.0 1.0 2.0 4.0 3.0 2.0 1.0 9.0 6.0 4.0 9.0 4.0 9.0 9.0 6.0 9.0 6.0 8.0 3.0 4.0 2.0 1.0 1.0 1.0 1.0 1.0 2.0 1978.0 43.0 3.0 2.0 1.0 1.0 1.0 504.0 504.0 504.0 1.0 4.0 1.0 170.0 1.0 2.0 2.0 1.0 4.0 2.0 1.0 1.0 1.0 1.0 5.0 2.0 0.0 3.0 6.0 2.0 2.0 2.0 3.0 3.0 1.0 5.0 50000000.0 504005.0 4.0 2.0 2.0 4.0 4.0 4.0 4.0 2.0 2.0 4.0 4.0 4.0 4.0 2.0 2.0 4.0 4.0 4.0 4.0 4.0 2.0 2.0 4.0 4.0 2.0 4.0 4.0 4.0 2.0 4.0 4.0 2.0 2.0 0.0 NaN NaN 2.0 2.0 -1.0 0.443333 0.221667 0.283194 0.483889 0.0 0.33 0.00 0.110000 0.00 0.0 1.000000 0.333333 1.0 1.0 1.0 1.000000 0.33 0.33 0.33 0.330000 0.0 0.0 0.0 0.000000 0.25 0.66 0.66 0.523333 0.666667 0.333333 0.333333 0.444444 0.33 0.0 0.165 0.165 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 1.0 0.0 1.0
1199 0.0 0.0 2021.0 504.0 MAR 600.0 MOR 504071200.0 20211213.0 202111.0 202112.0 17.40 18.13 34.0 2.0 504002.0 504012.0 504081.0 5.0 3.0 3.0 1.0 81.0 -2.73 34.94 170.0 ar 1.0 1.0 1.0 0.833333 31083.33333 1.0 1.0 2.0 4.0 1.0 1.0 1.0 2.0 1.0 1.0 2.0 2.0 1.0 1.0 2.0 2.0 2.0 1.0 2.0 2.0 2.0 1.0 2.0 1.0 2.0 2.0 1.0 3.0 1.0 3.0 3.0 1.0 4.0 2.0 1.0 1.0 3.0 3.0 1.0 1.0 1.0 1.0 1.0 2.0 3.0 1.0 2.0 2.0 1.0 7.0 8.0 7.0 4.0 2.0 4.0 4.0 4.0 1.0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2.0 2.0 4.0 5.0 2.0 2.0 5.0 2.0 2.0 4.0 2.0 5.0 5.0 3.0 2.0 4.0 4.0 2.0 2.0 2.0 2.0 2.0 4.0 4.0 2.0 2.0 4.0 2.0 2.0 1.0 1.0 1.0 0.331944 0.443889 0.311944 0.457222 0.5 0.33 0.00 0.276667 0.00 1.0 0.833333 0.611111 0.0 0.0 0.0 0.000000 0.00 0.66 0.66 0.440000 0.0 0.0 1.0 0.333333 0.75 0.00 0.66 0.470000 0.000000 0.666667 0.666667 0.444444 0.00 0.0 0.000 0.000 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 1.0

1200 rows × 430 columns

In [91]:
# setuping the variable view
variable_view = pd.DataFrame({
    "Variable Name": meta.column_names,
    "Label": meta.column_labels,
    "Values": [meta.variable_value_labels.get(var, {}) for var in meta.column_names]
})
In [92]:
variable_view.head(10)
Out[92]:
Variable Name Label Values
0 version Version of Data File {}
1 doi Digital Object Identifier {}
2 A_YEAR Year of survey {2017.0: '2017', 2018.0: '2018', 2019.0: '2019...
3 B_COUNTRY ISO 3166-1 numeric country code {504.0: 'Morocco'}
4 B_COUNTRY_ALPHA ISO 3166-1 alpha-3 country code {}
5 C_COW_NUM CoW country code numeric {600.0: 'Morocco'}
6 C_COW_ALPHA CoW country code alpha {}
7 D_INTERVIEW Interview ID {}
8 J_INTDATE Date of interview {-5.0: 'No answer; Missing; GB,NIRL: Postal su...
9 FW_START Year/month of start-fieldwork {}
In [93]:
# seting up the labeled view dataframe: labeled_df
labeled_df = df.copy()
for column, value_labels in meta.variable_value_labels.items():
    if column in labeled_df.columns:
        # Ensure consistent types between DataFrame values and value_labels keys
        value_labels = {float(k): v for k, v in value_labels.items()}  # Convert keys to float
        labeled_df[column] = labeled_df[column].map(value_labels).fillna(labeled_df[column])
In [94]:
labeled_df.head(5)
Out[94]:
version doi A_YEAR B_COUNTRY B_COUNTRY_ALPHA C_COW_NUM C_COW_ALPHA D_INTERVIEW J_INTDATE FW_START FW_END K_TIME_START K_TIME_END K_DURATION Q_MODE N_REGION_ISO N_REGION_WVS N_TOWN G_TOWNSIZE G_TOWNSIZE2 H_SETTLEMENT H_URBRURAL I_PSU O1_LONGITUDE O2_LATITUDE S_INTLANGUAGE LNGE_ISO E_RESPINT F_INTPRIVACY W_WEIGHT S018 PWGHT Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 Q13 Q14 Q15 Q16 Q17 Q18 Q19 Q20 Q21 Q22 Q23 Q24 Q25 Q26 Q27 Q28 Q29 Q30 Q31 Q32 Q33 Q33_3 Q34 Q34_3 Q35 Q35_3 Q37 Q38 Q39 Q40 Q41 Q42 Q43 Q44 Q45 Q46 Q47 Q48 Q49 Q50 Q51 Q52 Q53 Q54 Q55 Q56 Q57 Q58 Q59 Q60 Q61 Q62 Q63 Q64 Q65 Q66 Q67 Q68 Q69 Q70 Q71 Q72 Q73 Q74 Q75 Q76 Q77 Q78 Q79 Q80 Q81 Q82 Q82_ARABLEAGUE Q82_GULFCOOP Q82_ISLCOOP Q83 Q84 Q85 Q86 Q87 Q88 Q89 Q90 Q91 Q92 Q93 Q94 Q95 Q96 Q97 Q98 Q99 Q100 Q101 Q102 Q103 Q104 Q105 Q106 Q107 Q108 Q109 Q110 Q111 Q112 Q113 Q114 Q115 Q116 Q117 Q118 Q119 Q120 Q121 Q122 Q123 Q124 Q125 Q126 Q127 Q128 Q129 Q130 Q131 Q132 Q133 Q134 Q135 Q136 Q137 Q138 Q139 Q140 Q141 Q142 Q143 Q144 Q145 Q146 Q147 Q148 Q149 Q150 Q151 Q152 Q153 Q154 Q155 Q156 Q157 Q158 Q159 Q160 Q161 Q162 Q163 Q164 Q165 Q166 Q167 Q168 Q169 Q170 Q171 Q172 Q173 Q174 Q175 Q176 Q177 Q178 Q179 Q180 Q181 Q182 Q183 Q184 Q185 Q186 Q187 Q188 Q189 Q190 Q191 Q192 Q193 Q194 Q195 Q196 Q197 Q198 Q199 Q200 Q201 Q202 Q203 Q204 Q205 Q206 Q207 Q208 Q209 Q210 Q211 Q212 Q213 Q214 Q215 Q216 Q217 Q218 Q219 Q220 Q221 Q222 Q223 Q223_ABREV Q223_LOCAL Q224 Q225 Q226 Q227 Q228 Q229 Q230 Q231 Q232 Q233 Q234 Q234A Q235 Q236 Q237 Q238 Q239 Q240 Q241 Q242 Q243 Q244 Q245 Q246 Q247 Q248 Q249 Q250 Q251 Q252 Q253 Q254 Q255 Q256 Q257 Q258 Q259 Q260 Q261 Q262 X003R X003R2 Q263 Q264 Q265 Q266 Q267 Q268 Q269 Q270 Q271 Q272 Q273 Q274 Q275 Q275R Q276 Q276R Q277 Q277R Q278 Q278R Q279 Q280 Q281 Q282 Q283 Q284 Q285 Q286 Q287 Q288 Q288R Q289 Q289CS9 Q290 Q291G1 Q291G2 Q291G3 Q291G4 Q291G5 Q291G6 Q291P1 Q291P2 Q291P3 Q291P4 Q291P5 Q291P6 Q291UN1 Q291UN2 Q291UN3 Q291UN4 Q291UN5 Q291UN6 Q292A Q292B Q292C Q292D Q292E Q292F Q292G Q292H Q292I Q292J Q292K Q292L Q292M Q292N Q292O Q293 Q294A Q294B Y001 Y002 Y003 SACSECVAL SACSECVALB RESEMAVAL RESEMAVALB I_AUTHORITY I_NATIONALISM I_DEVOUT DEFIANCE I_RELIGIMP I_RELIGBEL I_RELIGPRAC DISBELIEF I_NORM1 I_NORM2 I_NORM3 RELATIVISM I_TRUSTARMY I_TRUSTPOLICE I_TRUSTCOURTS SCEPTICISM I_INDEP I_IMAGIN I_NONOBED AUTONOMY I_WOMJOB I_WOMPOL I_WOMEDU EQUALITY I_HOMOLIB I_ABORTLIB I_DIVORLIB CHOICE I_VOICE1 I_VOICE2 I_VOI2_00 VOICE SECVALWGT WEIGHT1A WEIGHT1B WEIGHT2A WEIGHT2B WEIGHT3A WEIGHT3B WEIGHT4A WEIGHT4B RESEMAVALBWGT RESEMAVALWGT SECVALBWGT Y001_1 Y001_2 Y001_3 Y001_4 Y001_5
0 0.0 0.0 2021 Morocco MAR Morocco MOR 504070001.0 20211112.0 202111.0 202112.0 10.05 10.43 38.0 Paper-and-Pencil Interviewing (PAPI) MA-09 Souss-Massa MA: MA-09 Souss-Massa MA: Afella Ighir Under 2,000 Under 5,000 Another city, town (not a regional or district... Rural 99.0 -8.84 29.49 Arabic ar Respondent was very interested There were other people around who could follo... No weighting 0.833333 31083.33333 Very important Rather important Very important Very important Very important Very important Important Not mentioned Important Important Not mentioned Not mentioned Not mentioned Not mentioned Important Not mentioned Important Mentioned Not mentioned Not mentioned Mentioned Mentioned Mentioned Not mentioned Mentioned Not mentioned Agree strongly Agree Agree strongly Disagree Agree strongly Agree strongly Agree Agree Agree strongly Agree Strongly agree Agree Agree Agree strongly Strongly agree Strongly agree Neither agree nor disagree Our society must be gradually improved by reforms Don't mind Good thing Bad thing Quite happy Fair 5 8 6 Never Rarely Never Never Never Or about the same Need to be very careful Trust completely Do not trust very much Trust somewhat Do not trust at all Do not trust at all Trust somewhat Quite a lot Not very much Not very much Quite a lot Not very much Not very much A great deal None at all None at all None at all Not very much Quite a lot A great deal A great deal Not very much A great deal Quite a lot Not very much Quite a lot Quite a lot Quite a lot Quite a lot Quite a lot Not very much Quite a lot Not very much None at all None at all Quite a lot 5 India Geneva Human rights Inactive member Don't belong Don't belong Not a member Not a member Don't belong Not a member Not a member Don't belong Don't belong Don't belong Don't belong 6 4 5 5 5 Economy growth and creating jobs 10 There is abundant corruption in my country Most of them Most of them Few of them Few of them Most of them Frequently Disagree 8 Neither good, nor bad Agree Agree Hard to say Agree Hard to say Agree Hard to say Disagree Place strict limits on the number of foreigner... Quite secure Not frequently Not frequently Quite frequently Quite frequently Not frequently Not frequently Not frequently Yes No Yes A great deal A great deal No No Very much Very much A great deal Equality Security No A high level of economic growth Seeing that people have more say about how ar... Maintaining order in the nation Protecting freedom of speech Progress toward a less impersonal and more hum... The fight against crime 6 8 8 5 6 8 Very important Yes Yes Yes Yes Strongly agree Strongly agree More than once a week Several times a day Not a religious person Do good to other people Make sense of life after death 4 5 Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable 7 2 Never justifiable 6 2 8 Never justifiable Never justifiable Never justifiable 3 Always justifiable Definitely should have the right Definitely should not have the right Definitely should not have the right Somewhat interested Never Never Daily Weekly Weekly Less than monthly Weekly Weekly Never Have done Have done Would never do Would never do Might do Would never do Might do Would never do Might do Would never do Would never do Would never do Usually Usually MAR: Authenticity and Modernity Party MAR: PAM MAR: Parti de l'Authenticite et de la Modernit... Very often Not often Fairly often Very often Very often Very often Very often Not at all often Not at all often Not often Rather important Not at all Very bad Very bad Very bad Fairly good Very good 8 An essential characteristic of democracy 7 6 9 4 8 9 5 An essential characteristic of democracy Absolutely important 3 Not satisfied at all Not much respect Not very proud Not close at all Not close at all Not close at all Not very close Not close at all Female 1969.0 52.0 45-54 50 and more years I am born in this country Not an immigrant Not an immigrant Morocco Morocco Morocco Yes 8.0 No Berber; Amazigh;Tamaziɣt Married 4 children Primary education (ISCED 1) Lower Early childhood education (ISCED 0) / no educa... Lower Early childhood education (ISCED 0) / no educa... Lower Early childhood education (ISCED 0) / no educa... Lower Full time (30 hours a week or more) Homemaker not otherwise employed Service (for example: restaurant owner, police... Farm worker (for example: farm labourer, tract... Farm worker (for example: farm labourer, tract... Private business or industry Yes Spent some savings Upper middle class Sixth step Medium Muslim Islam; nfd MA: Arabe Disagree strongly Agree Disagree strongly Disagree Disagree strongly Disagree strongly Disagree strongly Agree Disagree strongly Disagree Disagree strongly Disagree Neither agree nor disagree Disagree Disagree Agree Disagree strongly Neither agree nor disagree Agree strongly Agree Neither agree nor disagree Disagree Disagree Agree Disagree Disagree Disagree strongly Disagree strongly Disagree strongly Agree strongly Agree Disagree strongly Neither agree nor disagree 1 1 1 3 Mixed Obedience/Religious Faith 0.331667 0.443333 0.235139 0.262778 High High Very low 0.553333 Very low Not religious or atheist 0.000000 0.333333 Conformist Conformist Conformist 0.000000 Low Low Very high 0.44 No No No 0.000000 Medium-Low Very low High 0.303333 0.000000 0.000000 0.666667 0.222222 High Medio 0.415 0.415 1.0 Complete Complete Complete Complete Complete Complete Complete Complete 1.0 1.0 1.0 1 0 1 1 0
1 0.0 0.0 2021 Morocco MAR Morocco MOR 504070002.0 20211112.0 202111.0 202112.0 10.46 11.19 33.0 Paper-and-Pencil Interviewing (PAPI) MA-09 Souss-Massa MA: MA-09 Souss-Massa MA: Afella Ighir Under 2,000 Under 5,000 Another city, town (not a regional or district... Rural 99.0 -8.84 29.49 Arabic ar Respondent was very interested There were no other people around who could fo... No weighting 0.833333 31083.33333 Very important Rather important Not very important Not at all important Very important Very important Important Not mentioned Important Not mentioned Important Not mentioned Important Not mentioned Important Not mentioned Not mentioned Not mentioned Not mentioned Mentioned Mentioned Mentioned Not mentioned Not mentioned Not mentioned Not mentioned Agree strongly Agree strongly Agree strongly Disagree Agree strongly Agree strongly Agree strongly Agree Agree strongly Agree Disagree strongly Disagree Agree strongly Agree strongly Strongly agree Strongly agree Agree strongly Our present society must be valiantly defended... Bad thing Good thing Good thing Not at all happy Poor 5 4 2 Never Often Often Sometimes Never Or about the same Need to be very careful Trust completely Do not trust very much Do not trust at all Do not trust at all Do not trust at all Do not trust very much A great deal A great deal None at all None at all Not very much A great deal Not very much None at all None at all None at all Not very much Not very much None at all None at all None at all Quite a lot Quite a lot A great deal Not very much Not very much Not very much Quite a lot None at all None at all None at all None at all None at all None at all None at all 5 India London Human rights Active member Don't belong Active member Not a member Not a member Don't belong Not a member Not a member Don't belong Don't belong Don't belong Don't belong There should be greater incentives for individ... Government ownership of business should be inc... 9 6 6 Protecting environment 10 There is abundant corruption in my country Most of them All of them Most of them None of them All of them Always Hard to say Very high risk Rather bad Agree Agree Disagree Disagree Agree Agree Agree Agree Prohibit people coming here from other countries Quite secure Very Frequently Very Frequently Very Frequently Very Frequently Quite frequently Very Frequently Very Frequently Yes Yes No Very much Very much Yes Yes Very much Very much Very much Freedom Security Yes A high level of economic growth Trying to make our cities and countryside more... Maintaining order in the nation Fighting rising prices Progress toward a less impersonal and more hum... Progress toward a society in which Ideas count... Completely agree Completely agree Completely agree Completely agree 8 A lot worse off Not at all important Yes No No No Strongly disagree Strongly disagree Once a year Only on special holy days A religious person Do good to other people Make sense of life in this world 5 5 5 5 5 5 5 5 5 8 5 5 5 5 9 5 5 5 5 6 Definitely should have the right Definitely should not have the right Definitely should not have the right Somewhat interested Occasionally Less than monthly Less than monthly Never Daily Never Daily Daily Less than monthly Might do Have done Might do Might do Have done Might do Might do Would never do Might do Might do Would never do Would never do Never Never MAR: Justice and Development Party MAR: PJD MAR: Parti de la Justice et du Developpement -... Not at all often Not often Not at all often Not at all often Not at all often Not at all often Very often Very often Not often Fairly often Very important Not at all Very good Very good Very bad Very good Very good Left An essential characteristic of democracy An essential characteristic of democracy An essential characteristic of democracy An essential characteristic of democracy An essential characteristic of democracy An essential characteristic of democracy An essential characteristic of democracy An essential characteristic of democracy 5 8 6 7 Not much respect Very proud Very close Very close Close Not very close Not close at all Female 1998.0 23.0 16-24 16-29 years I am born in this country Not an immigrant Not an immigrant Morocco Morocco Morocco Yes 6 Yes, own parent(s) Berber; Amazigh;Tamaziɣt Single No children Bachelor or equivalent (ISCED 6) Higher Upper secondary education (ISCED 3) Middle Early childhood education (ISCED 0) / no educa... Lower Early childhood education (ISCED 0) / no educa... Lower Full time (30 hours a week or more) NaN Sales (for example: sales manager, shop owner,... NaN Skilled worker (for example: foreman, motor me... Private non-profit organization No Just get by Working class Seventh step Medium Muslim Islam; nfd MA: Arabe Disagree strongly Agree strongly Disagree strongly Disagree strongly Disagree strongly Disagree strongly Agree strongly Agree strongly Agree strongly Disagree strongly Disagree strongly Disagree strongly Agree strongly Disagree strongly Neither agree nor disagree Neither agree nor disagree Neither agree nor disagree Agree Agree strongly Agree strongly Disagree strongly Disagree strongly Agree strongly Agree Disagree Disagree strongly Disagree strongly Disagree strongly Disagree strongly Disagree strongly Agree strongly Disagree strongly Disagree strongly No trust at all NaN NaN 2 Materialist -1 0.360556 0.111111 0.360556 0.387778 Low Very low Very low 0.000000 Very low Religious 0.666667 0.222222 Inconformist Inconformist Inconformist 1.000000 Very high Very high Low 0.22 No Yes Yes 0.666667 Low Very low High 0.220000 0.444444 0.444444 0.777778 0.555556 Very high Bajo 0.000 0.000 1.0 Complete Complete Complete Complete Complete Complete Complete Complete 1.0 1.0 1.0 0 0 0 1 1
2 0.0 0.0 2021 Morocco MAR Morocco MOR 504070003.0 20211112.0 202111.0 202112.0 11.28 12.09 41.0 Paper-and-Pencil Interviewing (PAPI) MA-09 Souss-Massa MA: MA-09 Souss-Massa MA: Afella Ighir Under 2,000 Under 5,000 Another city, town (not a regional or district... Rural 99.0 -8.84 29.49 Arabic ar Respondent was very interested There were other people around who could follo... No weighting 0.833333 31083.33333 Very important Rather important Very important Not at all important Very important Very important Important Not mentioned Important Important Not mentioned Important Not mentioned Important Important Not mentioned Not mentioned Mentioned Not mentioned Not mentioned Not mentioned Mentioned Not mentioned Mentioned Not mentioned Not mentioned Agree strongly Agree strongly Agree strongly Disagree Agree Disagree Neither agree nor disagree Neither agree nor disagree Agree strongly Agree Strongly agree Agree Agree strongly Agree strongly Strongly agree Strongly agree Agree strongly The entire way our society is organized must b... Bad thing Good thing Good thing Not very happy Poor 2 2 3 Rarely Rarely Sometimes Often Often Worse off Need to be very careful Trust completely Do not trust at all Do not trust at all Do not trust at all Do not trust at all Do not trust at all Quite a lot A great deal Quite a lot Not very much None at all A great deal A great deal Not very much Not very much None at all A great deal Quite a lot None at all A great deal A great deal A great deal Not very much Not very much None at all None at all None at all None at all Not very much None at all None at all None at all A great deal Quite a lot A great deal 9 India Geneva Human rights Don't belong Active member Don't belong Not a member Not a member Don't belong Not a member Not a member Don't belong Don't belong Don't belong Don't belong Incomes should be made more equal Private ownership of business should be increased The government should take more responsibility... Competition is good In the long run, hard work usually brings a be... Protecting environment 10 There is abundant corruption in my country Few of them Most of them Few of them Few of them Most of them Always Strongly disagree Very high risk Quite good Disagree Agree Agree Agree Disagree Agree Agree Disagree Let people come as long as there are jobs avai... Quite secure Not frequently Not at all frequently Not at all frequently Quite frequently Not frequently Not frequently Very Frequently Yes Yes No Not at all A great deal Yes Yes Very much Very much Very much Equality Freedom Yes A high level of economic growth Making sure this country has strong defence fo... Maintaining order in the nation Protecting freedom of speech Progress toward a less impersonal and more hum... Progress toward a society in which Ideas count... 8 8 7 5 2 7 Very important Yes Yes Yes Yes Strongly agree Strongly agree Once a week Several times a day Not a religious person Follow religious norms and ceremonies Make sense of life after death 4 7 2 2 2 Never justifiable Never justifiable Never justifiable 4 7 2 Never justifiable Never justifiable 5 3 Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Definitely should have the right Probably should not have the right Probably should not have the right Not at all interested Never Never Never Never Never Never Never Weekly Weekly Would never do Would never do Would never do Would never do Would never do Would never do Would never do Would never do Might do Would never do Would never do Would never do Never Never None 4.0 4.0 Very often Not at all often Fairly often Not often Not often Very often Fairly often Not often Not often Very often Not very important Very little Very good Very good Fairly bad Fairly good Fairly good 8 An essential characteristic of democracy 7 An essential characteristic of democracy An essential characteristic of democracy 5 An essential characteristic of democracy 6 8 An essential characteristic of democracy Absolutely important 6 6 Fairly much respect Quite proud Very close Close Not close at all Not close at all Not close at all Male 1986.0 35.0 35-44 30-49 years I am born in this country Not an immigrant Not an immigrant Morocco Morocco Morocco Yes 4 Yes, own parent(s) Arabic Divorced 1 child Bachelor or equivalent (ISCED 6) Higher Post-secondary non-tertiary education (ISCED 4) Middle Bachelor or equivalent (ISCED 6) Higher Bachelor or equivalent (ISCED 6) Higher Unemployed NaN Farm worker (for example: farm labourer, tract... Farm worker (for example: farm labourer, tract... Farm worker (for example: farm labourer, tract... Private non-profit organization Yes Just get by Upper middle class Seventh step Medium Muslim Islam; nfd MA: Arabe Disagree strongly Disagree Agree strongly Disagree Disagree Agree strongly Disagree strongly Disagree strongly Agree Disagree Disagree Agree Agree Neither agree nor disagree Agree Neither agree nor disagree Agree Agree strongly Agree strongly Agree strongly Neither agree nor disagree Disagree Agree Agree strongly Disagree strongly Neither agree nor disagree Agree strongly Agree Disagree strongly Agree Agree Agree Disagree 7 NaN NaN 3 Mixed 0 0.291389 0.249444 0.304583 0.360000 Low Low Very low 0.110000 Very low Not religious or atheist 0.166667 0.388889 Inconformist Inconformist Conformist 0.666667 Very high Very high Very high 0.00 No No Yes 0.333333 Medium Very low High 0.386667 0.000000 0.333333 0.666667 0.333333 High Bajo 0.165 0.165 1.0 Complete Complete Complete Complete Complete Complete Complete Complete 1.0 1.0 1.0 0 0 1 1 1
3 0.0 0.0 2021 Morocco MAR Morocco MOR 504070004.0 20211112.0 202111.0 202112.0 12.08 12.42 34.0 Paper-and-Pencil Interviewing (PAPI) MA-09 Souss-Massa MA: MA-09 Souss-Massa MA: Afella Ighir Under 2,000 Under 5,000 Another city, town (not a regional or district... Rural 99.0 -8.84 29.49 Arabic ar Respondent was very interested There were no other people around who could fo... No weighting 0.833333 31083.33333 Very important Very important Not at all important Rather important Very important Very important Important Not mentioned Important Not mentioned Not mentioned Important Not mentioned Not mentioned Not mentioned Important Important Not mentioned Not mentioned Not mentioned Not mentioned Mentioned Not mentioned Not mentioned Not mentioned Not mentioned Agree strongly Agree strongly Agree strongly Disagree Disagree Agree strongly Agree strongly Agree Agree strongly Agree Strongly agree Agree Agree strongly Agree strongly Strongly agree Strongly agree Agree strongly Our present society must be valiantly defended... Bad thing Good thing Good thing Quite happy Very good 8 Completely dissatisfied 6 Never Rarely Never Never Never Or about the same Need to be very careful Trust completely Do not trust very much Do not trust very much Do not trust at all Do not trust very much Do not trust very much Not very much A great deal None at all None at all None at all A great deal A great deal Not very much None at all None at all None at all None at all None at all None at all None at all None at all None at all None at all Not very much Not very much Not very much Not very much Not very much None at all None at all Not very much None at all None at all None at all Being democratic India Geneva Human rights Don't belong Don't belong Don't belong Not a member Not a member Don't belong Not a member Not a member Don't belong Don't belong Don't belong Don't belong There should be greater incentives for individ... Government ownership of business should be inc... People should take more responsibility to prov... Competition is harmful Hard work doesn't generally bring success - it... Economy growth and creating jobs 7 Few of them Most of them Few of them Few of them Most of them Frequently Strongly agree Very high risk Quite good Agree Disagree Hard to say Hard to say Disagree Disagree Agree Disagree Place strict limits on the number of foreigner... Very Secure Not frequently Quite frequently Quite frequently Not at all frequently Quite frequently Not frequently Very Frequently Yes Yes Yes Very much Very much No No Very much Very much Very much Equality Freedom Yes A high level of economic growth Trying to make our cities and countryside more... Maintaining order in the nation Fighting rising prices A stable economy Progress toward a society in which Ideas count... Completely agree Completely agree Completely agree 8 Completely disagree A lot better off Very important Yes Yes Yes Yes Strongly agree Strongly agree More than once a week Several times a day A religious person Do good to other people Make sense of life in this world Completely agree 5 Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Definitely should have the right Definitely should not have the right Definitely should not have the right Somewhat interested Occasionally Less than monthly Daily Less than monthly Daily Daily Daily Daily Daily Would never do Have done Would never do Would never do Have done Might do Have done Have done Have done Have done Have done Have done Usually Usually None 4.0 4.0 Not often Not often Very often Very often Not often Fairly often Fairly often Fairly often Very often Fairly often Very important Some Very good Very bad Very bad Very bad Bad 5 An essential characteristic of democracy An essential characteristic of democracy An essential characteristic of democracy An essential characteristic of democracy Not an essential characteristic of democracy An essential characteristic of democracy An essential characteristic of democracy Not an essential characteristic of democracy Not an essential characteristic of democracy Absolutely important 6 6 A great deal of respect Very proud Close Not close at all Not close at all Not close at all Not close at all Male 1993.0 28.0 25-34 16-29 years I am born in this country Not an immigrant Not an immigrant Morocco Morocco Morocco Yes 4 Yes, own parent(s) Arabic Married 2 children Primary education (ISCED 1) Lower Early childhood education (ISCED 0) / no educa... Lower Lower secondary education (ISCED 2) Lower Lower secondary education (ISCED 2) Lower Unemployed Full time (30 hours a week or more) Clerical (for example: secretary, clerk, offic... Never had a job Farm worker (for example: farm labourer, tract... Private business or industry No Just get by Lower middle class Sixth step Medium Muslim Islam; nfd MA: Arabe Agree Agree strongly Agree strongly Agree Disagree strongly Neither agree nor disagree Disagree Agree strongly Agree strongly Agree Disagree strongly Disagree Agree strongly Agree strongly Agree strongly Neither agree nor disagree Disagree Disagree Agree Agree Agree Agree Agree Disagree Agree Agree Agree Agree Agree Agree Agree Agree Agree 5 NaN NaN 1 Materialist -1 0.000000 0.000000 0.055000 0.110000 Low Very low Very low 0.000000 Very low Religious 0.000000 0.000000 Conformist Conformist Conformist 0.000000 Very high Very high Very high 0.00 No No No 0.000000 Low Very low High 0.220000 0.000000 0.000000 0.000000 0.000000 Very high Bajo 0.000 0.000 1.0 Complete Complete Complete Complete Complete Complete Complete Complete 1.0 1.0 1.0 0 0 0 0 1
4 0.0 0.0 2021 Morocco MAR Morocco MOR 504070005.0 20211112.0 202111.0 202112.0 13.18 13.55 37.0 Paper-and-Pencil Interviewing (PAPI) MA-09 Souss-Massa MA: MA-09 Souss-Massa MA: Afella Ighir Under 2,000 Under 5,000 Another city, town (not a regional or district... Rural 99.0 -8.84 29.49 Arabic ar Respondent was very interested There were no other people around who could fo... No weighting 0.833333 31083.33333 Very important Rather important Not very important Not very important Very important Very important Important Important Not mentioned Important Not mentioned Not mentioned Not mentioned Important Not mentioned Important Not mentioned Mentioned Not mentioned Mentioned Not mentioned Mentioned Not mentioned Mentioned Not mentioned Not mentioned Agree strongly Agree strongly Disagree Disagree Agree Agree strongly Agree strongly Agree Agree strongly Agree Neither agree nor disagree Neither agree nor disagree Neither agree nor disagree Agree Disagree Disagree Neither agree nor disagree The entire way our society is organized must b... Bad thing Don't mind Don't mind Not very happy Good 7 7 4 Sometimes Rarely Sometimes Never Never Or about the same Need to be very careful Trust completely Do not trust very much Trust somewhat Do not trust very much Do not trust very much Do not trust very much Quite a lot Quite a lot Not very much Not very much Not very much Not very much Not very much Not very much Not very much None at all Not very much None at all None at all Not very much Not very much Not very much Not very much Not very much Not very much Not very much Not very much Not very much Not very much Not very much Not very much Not very much Not very much Not very much Not very much 5 China Washington DC Destruction of historic monuments Inactive member Active member Inactive member Inactive member Inactive member Inactive member Inactive member Inactive member Inactive member Inactive member Inactive member Don't belong 6 5 3 Competition is good 5 Protecting environment 8 Most of them Most of them Most of them Most of them Most of them Frequently Strongly disagree Very high risk Neither good, nor bad Agree Hard to say Hard to say Hard to say Disagree Agree Disagree Hard to say Let people come as long as there are jobs avai... Very Secure Quite frequently Quite frequently Not at all frequently Quite frequently Quite frequently Quite frequently Very Frequently Yes No No A great deal Very much No No Very much Very much Very much Equality Security No A high level of economic growth Making sure this country has strong defence fo... Maintaining order in the nation Fighting rising prices A stable economy Progress toward a less impersonal and more hum... 8 Completely agree 7 6 Completely disagree 8 Very important Yes Yes Yes Yes Strongly agree Strongly agree More than once a week Several times a day Not a religious person Follow religious norms and ceremonies Make sense of life after death 7 Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable Never justifiable 3 Never justifiable 4 Never justifiable 8 2 Never justifiable 4 5 Always justifiable Definitely should have the right Definitely should not have the right Definitely should not have the right Not at all interested Never Never Never Never Never Never Daily Daily Monthly Would never do Would never do Would never do Would never do Would never do Would never do Would never do Would never do Might do Would never do Would never do Would never do Never Never None 4.0 4.0 Very often Fairly often Not at all often Fairly often Fairly often Very often Fairly often Not often Fairly often Very often Not very important Very little Very bad Fairly bad Very bad Very good Very good 7 Not an essential characteristic of democracy 3 5 9 6 An essential characteristic of democracy An essential characteristic of democracy 3 9 8 5 3 Not much respect Not very proud Close Close Not very close Not very close Not close at all Male 1999.0 22.0 16-24 16-29 years I am born in this country Not an immigrant Not an immigrant Morocco Morocco Morocco Yes 5 No Arabic Single No children Primary education (ISCED 1) Lower NaN NaN Upper secondary education (ISCED 3) Middle Lower secondary education (ISCED 2) Lower Full time (30 hours a week or more) NaN Service (for example: restaurant owner, police... NaN Farm worker (for example: farm labourer, tract... Private non-profit organization No Spent some savings Working class Seventh step Medium Muslim Islam; nfd MA: Arabe Agree Disagree Agree strongly Agree strongly Disagree Disagree strongly Disagree Disagree Agree Agree Disagree Agree Disagree Disagree Agree strongly Disagree Disagree Disagree Agree strongly Agree strongly Disagree Disagree Agree Agree strongly Disagree strongly Disagree strongly Agree strongly Agree strongly Disagree strongly Agree strongly Agree strongly Agree Agree strongly 2 1 1 1 Materialist Determination, perseverance/Independence 0.317500 0.360000 0.276667 0.220000 Medium High Very low 0.386667 Very low Not religious or atheist 0.000000 0.333333 Conformist Conformist Conformist 0.000000 High Low Low 0.55 Yes No Yes 0.666667 Low High High 0.440000 0.000000 0.000000 0.000000 0.000000 Very high Bajo 0.000 0.000 1.0 Complete Complete Complete Complete Complete Complete Complete Complete 1.0 1.0 1.0 0 0 0 0 1
In [95]:
# searching for anything that contains the letters that are in Satisfaction
variable_view[variable_view['Label'].str.contains('Sati')]
Out[95]:
Variable Name Label Values
82 Q49 Satisfaction with your life {-5.0: 'Other missing; Multiple answers Mail (...
83 Q50 Satisfaction with financial situation of house... {-5.0: 'Missing; Unknown', -4.0: 'Not asked', ...
291 Q252 Satisfaction with the political system perform... {-5.0: 'Other missing; Multiple answers Mail (...
In [96]:
# searching for anything that contains the letters that are in Happiness 
variable_view[variable_view['Label'].str.contains('hap')]
Out[96]:
Variable Name Label Values
79 Q46 Feeling of happiness {-5.0: 'Other missing; Multiple answers Mail (...
In [97]:
# combining the results that we want
DataFrame = pd.DataFrame({
    'Satisfaction with financial situation of household (NV_Q50)': df['Q50'],
    'Feeling of happiness (NV_Q46)': df['Q46'],
    'Feeling of happiness (LV_Q46)': labeled_df['Q46'],
})
In [98]:
DataFrame
Out[98]:
Satisfaction with financial situation of household (NV_Q50) Feeling of happiness (NV_Q46) Feeling of happiness (LV_Q46)
0 6.0 2.0 Quite happy
1 2.0 4.0 Not at all happy
2 3.0 3.0 Not very happy
3 6.0 2.0 Quite happy
4 4.0 3.0 Not very happy
... ... ... ...
1195 6.0 1.0 Very happy
1196 6.0 2.0 Quite happy
1197 3.0 2.0 Quite happy
1198 3.0 2.0 Quite happy
1199 7.0 2.0 Quite happy

1200 rows × 3 columns

In [99]:
# setting up the frequency table for Feeling of happiness
FoH_frequency_df = DataFrame[['Feeling of happiness (LV_Q46)','Feeling of happiness (NV_Q46)']].value_counts().reset_index().sort_values(by='Feeling of happiness (NV_Q46)')
# calculating the percentages of Feeling of happiness
perFoH = DataFrame[['Feeling of happiness (LV_Q46)']].value_counts(normalize=True)*100
# merge Percentage of Feeling of happiness
FoH_frequency_df = FoH_frequency_df.merge(perFoH, on='Feeling of happiness (LV_Q46)')
#rename the proportion to perFoH
FoH_frequency_df.rename(columns={'proportion':'perFoH'}, inplace=True)
#calculating the mean
mean_SFSH=DataFrame.groupby('Feeling of happiness (LV_Q46)')['Satisfaction with financial situation of household (NV_Q50)'].mean().reset_index().sort_values(by= 'Feeling of happiness (LV_Q46)', ascending=False)
# mearging the mean of Satisfaction with financial situation of household with Feeling of happiness frequency table
FoH_frequency_df=FoH_frequency_df.merge(mean_SFSH, how='left', on='Feeling of happiness (LV_Q46)')

FoH_frequency_df.rename(columns={'Satisfaction with financial situation of household (NV_Q50)':'mean_SFSH'}, inplace=True)
In [100]:
FoH_frequency_df
Out[100]:
Feeling of happiness (LV_Q46) Feeling of happiness (NV_Q46) count perFoH mean_SFSH
0 Very happy 1.0 149 12.416667 7.677852
1 Quite happy 2.0 845 70.416667 6.431953
2 Not very happy 3.0 195 16.250000 4.492308
3 Not at all happy 4.0 11 0.916667 2.818182
In [101]:
# calculate the mode and median
Mode_FOH = DataFrame['Feeling of happiness (NV_Q46)'].mode()[0] # Get the first mode
Median_FOH = DataFrame['Feeling of happiness (NV_Q46)'].median()

# assign the mode and median to the columns (handling missing values)
FoH_frequency_df['Mode_FOH'] = Mode_FOH
FoH_frequency_df['Median_FOH'] = Median_FOH

# fill any NaN values if needed
FoH_frequency_df['Mode_FOH'].fillna(Mode_FOH, inplace=True)
FoH_frequency_df['Median_FOH'].fillna(Median_FOH, inplace=True)


order = ['Feeling of happiness (LV_Q46)','Feeling of happiness (NV_Q46)','perFoH','Median_FOH','Mode_FOH','count','mean_SFSH']

FoH_frequency_df[order]
Out[101]:
Feeling of happiness (LV_Q46) Feeling of happiness (NV_Q46) perFoH Median_FOH Mode_FOH count mean_SFSH
0 Very happy 1.0 12.416667 2.0 2.0 149 7.677852
1 Quite happy 2.0 70.416667 2.0 2.0 845 6.431953
2 Not very happy 3.0 16.250000 2.0 2.0 195 4.492308
3 Not at all happy 4.0 0.916667 2.0 2.0 11 2.818182
In [102]:
Mode_FEC = (
    DataFrame.groupby('Feeling of happiness (LV_Q46)')['Feeling of happiness (NV_Q46)']
    .agg(lambda x: x.mode())
    .reset_index()
    .sort_values(by='Feeling of happiness (LV_Q46)', ascending=False)
    .rename(columns={'Feeling of happiness (NV_Q46)': 'Mode_FEC'})
)

Median_FEC = (
    DataFrame.groupby('Feeling of happiness (LV_Q46)')['Feeling of happiness (NV_Q46)']
    .agg(lambda x: x.median())
    .reset_index()
    .sort_values(by='Feeling of happiness (LV_Q46)', ascending=False)
    .rename(columns={'Feeling of happiness (NV_Q46)': 'Median_FEC'})
)


FoH_frequency_df=FoH_frequency_df.merge(Mode_FEC, how='left',on='Feeling of happiness (LV_Q46)')

FoH_frequency_df=FoH_frequency_df.merge(Median_FEC, how='left',on='Feeling of happiness (LV_Q46)')

FoH_frequency_df
Out[102]:
Feeling of happiness (LV_Q46) Feeling of happiness (NV_Q46) count perFoH mean_SFSH Mode_FOH Median_FOH Mode_FEC Median_FEC
0 Very happy 1.0 149 12.416667 7.677852 2.0 2.0 1.0 1.0
1 Quite happy 2.0 845 70.416667 6.431953 2.0 2.0 2.0 2.0
2 Not very happy 3.0 195 16.250000 4.492308 2.0 2.0 3.0 3.0
3 Not at all happy 4.0 11 0.916667 2.818182 2.0 2.0 4.0 4.0
In [103]:
# Create a violing plot
fig = px.violin(
    DataFrame,
    x='Feeling of happiness (LV_Q46)', 
    y='Satisfaction with financial situation of household (NV_Q50)',
    box=True,  # Add boxplot overlay
    points='all',  # Show all data points
    title="The value of Satisfaction with financial situation of household based on Feeling of happiness",
    hover_data=['Satisfaction with financial situation of household (NV_Q50)', 
                'Feeling of happiness (LV_Q46)']  # Cleaner hover data specification
)

# Update the order of categories
fig.update_layout(
    xaxis=dict(
        categoryorder='array', 
        categoryarray=['Not at all happy', 'Not very happy', 'Quite happy', 'Very happy']
    ),
    plot_bgcolor='rgba(240, 240, 240, 1)',  # Light background color
    title_font=dict(size=24, family='Arial', color='black'),  # Title font styling
    xaxis_title='Feeling of happiness',
    yaxis_title='Satisfaction with financial situation of household',
    legend=dict(title='Category', orientation='h', x=0.5, xanchor='center'),
)

# Update the violins for styling
fig.update_traces(
    width=0.5,  # Thinner violins
    line_color='black',  # Black outline
    meanline_visible=True,  # Show mean line
    scalemode='count',  # Adjust width by the count of observations
    fillcolor='rgba(0,0,0,0)',  # Remove fill
)

# Show the plot
fig.show()
In [104]:
#pio.write_html(fig=fig, auto_open='True' ,file='xdplot.html')
In [105]:
DataFrame[['Feeling of happiness (NV_Q46)']].corrwith(DataFrame['Satisfaction with financial situation of household (NV_Q50)']).reset_index(name='Satisfaction with financial situation of household')
Out[105]:
index Satisfaction with financial situation of household
0 Feeling of happiness (NV_Q46) -0.438542

image.png


Fixing the "Feeling of Happiness" Scale¶

When I calculated the correlation between Feeling of happiness (LV_Q46) and Satisfaction with financial situation of household (NV_Q50), I got a negative result, which didn’t make sense. After checking the data, I realized that the scale for Feeling of happiness (LV_Q46) was flipped meaning higher numbers showed less happiness, and lower numbers showed more happiness.

To fix this, I created a function to reverse the scale, so that higher numbers now represent more happiness. The new scale works like this:

  • 1 → 4
  • 2 → 3
  • 3 → 2
  • 4 → 1

which will be:

  • 4: Very happy
  • 3: Quite happy
  • 2: Not very happy
  • 1: Not at all happy

I applied this change and added a new column called Feeling of happiness (NV_Q46)_reversed to the dataset. Now, the values are in the correct order for further analysis.

Here’s the function I used to reverse the scale:

In [106]:
# mapping the old scale of Feeling o happiness with new scale 
def reverse_happiness(value):
    if pd.notnull(value):  # Ensure the value is not NaN
        mapping = {1: 4, 2: 3, 3: 2, 4: 1}
        return mapping.get(value, value)  # Return mapped value or the value itself if not in mapping
    return value
DataFrame['Feeling of happiness (NV_Q46)_reversed'] = DataFrame['Feeling of happiness (NV_Q46)'].apply(reverse_happiness)
In [107]:
DataFrame
Out[107]:
Satisfaction with financial situation of household (NV_Q50) Feeling of happiness (NV_Q46) Feeling of happiness (LV_Q46) Feeling of happiness (NV_Q46)_reversed
0 6.0 2.0 Quite happy 3
1 2.0 4.0 Not at all happy 1
2 3.0 3.0 Not very happy 2
3 6.0 2.0 Quite happy 3
4 4.0 3.0 Not very happy 2
... ... ... ... ...
1195 6.0 1.0 Very happy 4
1196 6.0 2.0 Quite happy 3
1197 3.0 2.0 Quite happy 3
1198 3.0 2.0 Quite happy 3
1199 7.0 2.0 Quite happy 3

1200 rows × 4 columns

In [108]:
DataFrame[['Feeling of happiness (NV_Q46)_reversed']].corrwith(DataFrame['Satisfaction with financial situation of household (NV_Q50)']).reset_index(name='Satisfaction with financial situation of household')
Out[108]:
index Satisfaction with financial situation of household
0 Feeling of happiness (NV_Q46)_reversed 0.438542

With this fix, the analysis is now based on the correct Feeling of happiness (NV_Q46)_reversed values, so the results should be more meaningful.


What Does a Correlation of 0.44 Mean?¶

A correlation of 0.438542 tells us how Feeling of happiness and Satisfaction with financial situation are related. In simple terms:

  • Positive Correlation: The positive number means that when people feel more satisfied with their finances, they tend to feel happier too. So, if someone's financial situation improves, their happiness often increases as well.

  • Strength of the Relationship: A correlation of 0.44 is considered a moderate relationship. It's not super strong (like 0.9), but it's not weak either. It shows there's a noticeable link, but it’s not the only thing that matters.

  • What This Means: This result tells us that financial satisfaction and happiness are connected, but it's not the whole story. While improving financial satisfaction can make people happier, other things like health, relationships, or personal goals might also be affecting how happy they feel.


Regression and Why I Use Ordinal Regression¶

Regression is a statistical method used to understand the relationship between a dependent variable and one or more independent variables. It helps in predicting the value of the dependent variable based on the independent variables in other words, Regression is a method used to understand how different factors (independent variables) affect something we want to predict (dependent variable). It helps us estimate the value of one thing based on others.

Why Use Ordinal Regression¶

We use ordinal regression when we want to predict outcomes that have ordered categories. For example, when predicting levels of happiness, where the categories have a clear order:

  • 1: Not at all happy
  • 2: Not very happy
  • 3: Quite happy
  • 4: Very happy

Ordinal regression helps us understand the relationship between independent variables and these ordered categories, while respecting the order of the categories. Unlike other methods, it accounts for the fact that the difference between categories might not be the same (for example, the difference between "Not at all happy" and "Not very happy" might not be the same as between "Quite happy" and "Very happy").

The categories have a natural order, but the distance between them is not necessarily equal. In such cases, ordinal regression is the best choice.

Why Not Linear or Logistic Regression?¶

  • Linear Regression assumes the dependent variable is continuous (like height or income) and has equal spacing between values. This is not suitable for ordinal data where the differences between categories may not be equal.

  • Logistic Regression is used for binary outcomes (yes/no) or for nominal data (multiple categories without order). It doesn’t account for the order of categories, so it’s not appropriate for ordinal data.

In [109]:
# Independent and dependent variables
X = DataFrame[['Satisfaction with financial situation of household (NV_Q50)']]  # Independent variable
y = DataFrame['Feeling of happiness (NV_Q46)_reversed']  # Ordinal dependent variable

# Fit the ordered logit model (ordinal regression)
model = OrderedModel(y, X, distr='logit')  # 'logit' specifies the logit link function
result = model.fit()

# Print the model summary
print(result.summary())

# Predict probabilities for each category
predictions = result.predict(X)

# Convert predictions to a NumPy array
predictions = predictions.to_numpy()

# Create a DataFrame to hold the predicted probabilities for each category
predictions_df = pd.DataFrame(predictions, columns=[f'Prob of Category {i+1}' for i in range(predictions.shape[1])])

# Add the satisfaction variable (X) to the DataFrame for plotting
predictions_df['Satisfaction with financial situation'] = DataFrame['Satisfaction with financial situation of household (NV_Q50)']

# Convert the DataFrame into long format for Plotly Express
predictions_long_df = predictions_df.melt(id_vars=['Satisfaction with financial situation'], 
                                        value_vars=[f'Prob of Category {i+1}' for i in range(predictions.shape[1])],
                                        var_name='Category',
                                        value_name='Probability')

# Map the happiness categories to human-readable labels
category_mapping = {0: 'Not at all happy',
                1: 'Not very happy',
                2: 'Quite happy',
                3: 'Very happy'}

# Extract category number from the 'Category' column and map to human-readable labels
predictions_long_df['Happiness Category'] = predictions_long_df['Category'].apply(
    lambda x: category_mapping[int(x.split()[-1])-1])  # map based on the category index (e.g. Category 1 -> Not at all happy)

# Plot the predicted probabilities using Plotly Express
fig = px.scatter(predictions_long_df, 
                x='Satisfaction with financial situation', 
                y='Probability', 
                color='Happiness Category',  # This column contains the mapped labels
                title='Ordinal Regression: Predicted Probabilities of Happiness based on Satisfaction with Financial Situation',
                labels={'Satisfaction with financial situation': 'Satisfaction with Financial Situation',
                        'Probability': 'Predicted Probability',
                        'Happiness Category': 'Happiness Level'})

# Update legend title
fig.update_layout(
    legend_title='Happiness Levels'  # This is the new title for the legend
)

# Show the plot
fig.show()
Optimization terminated successfully.
         Current function value: 0.740002
         Iterations: 162
         Function evaluations: 277
                                       OrderedModel Results                                       
==================================================================================================
Dep. Variable:     Feeling of happiness (NV_Q46)_reversed   Log-Likelihood:                -888.00
Model:                                       OrderedModel   AIC:                             1784.
Method:                                Maximum Likelihood   BIC:                             1804.
Date:                                    Sat, 29 Mar 2025                                         
Time:                                            16:23:41                                         
No. Observations:                                    1200                                         
Df Residuals:                                        1196                                         
Df Model:                                               1                                         
===============================================================================================================================
                                                                  coef    std err          z      P>|z|      [0.025      0.975]
-------------------------------------------------------------------------------------------------------------------------------
Satisfaction with financial situation of household (NV_Q50)     0.5065      0.034     14.780      0.000       0.439       0.574
1/2                                                            -2.0937      0.340     -6.157      0.000      -2.760      -1.427
2/3                                                             1.2139      0.090     13.491      0.000       1.038       1.390
3/4                                                             1.4424      0.033     43.198      0.000       1.377       1.508
===============================================================================================================================

Interpretation of the Ordinal Regression Results¶

What Was Tested¶

  • Outcome Variable: "Feeling of happiness (NV_Q46)_reversed"
    This is an ordered variable. The term “reversed” suggests that the coding was flipped from the original so that the direction of the scale is switched.

  • Predictor: "Satisfaction with financial situation of household (NV_Q50)"
    This variable measures how satisfied people are with their household’s financial situation.

Key Results¶

  1. Satisfaction with Financial Situation (NV_Q50):

    • Coefficient: 0.5065
      A positive coefficient means that as satisfaction increases, the odds of moving to a higher category on the reversed happiness scale also increase.
    • Statistical Significance:
      The very high z-value (14.780) and p-value (0.000) indicate that this relationship is very unlikely to be due to chance.
    • Interpretation in Odds:
      If you exponentiate the coefficient (e^0.5065 ≈ 1.66), it tells us that for each one-unit increase in satisfaction, the odds of being in a higher happiness category increase by about 66%.
  2. Thresholds (Cut-off Points Between Categories):

    • These values (at -2.0937, 1.2139, and 1.4424) are not predictors but markers that separate the different categories of the happiness variable.
    • They help the model decide where one category ends and the next begins on the latent (hidden) scale that the model estimates.

Overall Interpretation¶

  • Main Finding:
    There is a strong and significant association between satisfaction with the household’s financial situation and the reported feeling of happiness (after reversing the scale).
  • Practical Meaning:
    As people report being more satisfied with their finances, they are more likely to move into a different category of the reversed happiness measure. What “higher category” means depends on how the reversed scale is set up—if a higher number means less happiness, then increased satisfaction could be linked with lower happiness. Conversely, if it was reversed to make higher values mean more happiness, the interpretation would flip. The key is that there is a strong link between financial satisfaction and the way happiness is categorized.

Each of the coefficients and thresholds in the table is statistically significant, which means we can be quite confident in these findings based on the sample of 1200 observations.


Exploring Regional Differences¶

Now that we know financial satisfaction affects happiness, the next step is to check if this relationship changes across different regions of Morocco. By looking at regional patterns, we can see if local factors, like economic conditions or cultural differences, play a role.

In this part, we will use maps and visualizations to explore and compare trends across regions for a clearer understanding.

But before we need to setup the geojson file and dataframe that we will use.

In [110]:
# setupping the map
morocco_data = gpd.read_file("ma.json")
morocco_data.drop(columns='source',inplace=True)
# if the file was in goejson fiormat u need to load t as json format 
#morocco_geojson = json.loads(morocco_data.to_json())
In [111]:
morocco_data
Out[111]:
id name geometry
0 MA11 Laâyoune-Sakia El Hamra POLYGON ((-8.75659 27.14772, -8.75422 27.14715...
1 MA01 Tangier-Tetouan-Al Hoceima POLYGON ((-3.82389 35.19936, -3.82346 35.19887...
2 MA02 Oriental POLYGON ((-3.82012 34.88753, -3.81998 34.89199...
3 MA08 Drâa-Tafilalet POLYGON ((-4.01816 32.60844, -4.00295 32.57946...
4 MA09 Souss-Massa POLYGON ((-7.73179 31.13463, -7.73274 31.13365...
5 MA10 Guelmim-Oued Noun POLYGON ((-8.75659 27.14772, -8.80915 27.16043...
6 MA06 Casablanca-Settat POLYGON ((-9.05932 32.72101, -9.05904 32.7215,...
7 MA07 Marrakech-Safi POLYGON ((-7.18452 31.42896, -7.1929 31.42544,...
8 MA12 Dakhla-Oued Ed-Dahab POLYGON ((-14.90488 24.6832, -14.89861 24.6739...
9 MA04 Rabat-Salé-Kenitra POLYGON ((-6.2434 35.00139, -6.23397 34.99872,...
10 MA03 Fez-Meknes POLYGON ((-5.31515 34.5159, -5.28082 34.51478,...
11 MA05 Béni Mellal-Khénifra POLYGON ((-5.25455 32.86937, -5.25284 32.86344...
In [112]:
labeled_df['N_REGION_ISO']
Out[112]:
0       MA-09 Souss-Massa
1       MA-09 Souss-Massa
2       MA-09 Souss-Massa
3       MA-09 Souss-Massa
4       MA-09 Souss-Massa
              ...        
1195     MA-02 L'Oriental
1196     MA-02 L'Oriental
1197     MA-02 L'Oriental
1198     MA-02 L'Oriental
1199     MA-02 L'Oriental
Name: N_REGION_ISO, Length: 1200, dtype: object
In [113]:
# functoin to seperate the region id from its name
id_list = []
regions_name = []
y = labeled_df['N_REGION_ISO'].str.split(' ')
for x in y:
    id_list.append(x[0])
    regions_name.append(x[1])
In [114]:
# creating the dataframe the will be ploted 'chromaplot_df'
chromaplot_df = pd.DataFrame({
    'Satisfaction with financial situation of household (NV_Q50)': df['Q50'],
    'Feeling of happiness (NV_Q46)': df['Q46'],
    'Feeling of happiness (NV_Q46)_reversed': DataFrame['Feeling of happiness (NV_Q46)_reversed'],
    'Feeling of happiness (LV_Q46)': labeled_df['Q46'],
    'N_REGION_ISO': labeled_df['N_REGION_ISO'],
    
})
chromaplot_df['ID_list'] = id_list
chromaplot_df['ID_list']= chromaplot_df['ID_list'].str.replace('-', '')

chromaplot_df['regions_name'] = regions_name
In [115]:
chromaplot_df
Out[115]:
Satisfaction with financial situation of household (NV_Q50) Feeling of happiness (NV_Q46) Feeling of happiness (NV_Q46)_reversed Feeling of happiness (LV_Q46) N_REGION_ISO ID_list regions_name
0 6.0 2.0 3 Quite happy MA-09 Souss-Massa MA09 Souss-Massa
1 2.0 4.0 1 Not at all happy MA-09 Souss-Massa MA09 Souss-Massa
2 3.0 3.0 2 Not very happy MA-09 Souss-Massa MA09 Souss-Massa
3 6.0 2.0 3 Quite happy MA-09 Souss-Massa MA09 Souss-Massa
4 4.0 3.0 2 Not very happy MA-09 Souss-Massa MA09 Souss-Massa
... ... ... ... ... ... ... ...
1195 6.0 1.0 4 Very happy MA-02 L'Oriental MA02 L'Oriental
1196 6.0 2.0 3 Quite happy MA-02 L'Oriental MA02 L'Oriental
1197 3.0 2.0 3 Quite happy MA-02 L'Oriental MA02 L'Oriental
1198 3.0 2.0 3 Quite happy MA-02 L'Oriental MA02 L'Oriental
1199 7.0 2.0 3 Quite happy MA-02 L'Oriental MA02 L'Oriental

1200 rows × 7 columns

In [116]:
# calculating  the mean of Feeling of happiness for each region 
aggregated_data_FoH = chromaplot_df.groupby(['ID_list','N_REGION_ISO'])['Feeling of happiness (NV_Q46)_reversed'].mean().reset_index()
aggregated_data_FoH
Out[116]:
ID_list N_REGION_ISO Feeling of happiness (NV_Q46)_reversed
0 MA01 MA-01 Tanger-Tetouan-Al Hoceima 2.941667
1 MA02 MA-02 L'Oriental 3.137500
2 MA03 MA-03 Fes-Meknes 3.020000
3 MA04 MA-04 Rabat-Sale-Kenitra 2.911765
4 MA05 MA-05 Beni Mellal-Khenifra 2.812500
5 MA06 MA-06 Casablanca-Settat 2.934615
6 MA07 MA-07 Marrakech-Safi 2.893333
7 MA08 MA-08 Draa-Tafilalet 2.980000
8 MA09 MA-09 Souss-Massa 2.940000
9 MA10 MA-10 Guelmim-Oued Noun 2.900000
10 MA11 MA-11 Laayoune-Sakia El Hamra (EH-partial) 2.800000
11 MA12 MA-12 Dakhla-Oued Ed-Dahab (EH) 3.000000
In [117]:
# calculating  the mean of Satisfaction with financial situation of household for each region 
aggregated_data_SFHS = chromaplot_df.groupby(['ID_list','N_REGION_ISO'])['Satisfaction with financial situation of household (NV_Q50)'].mean().reset_index()
aggregated_data_SFHS
Out[117]:
ID_list N_REGION_ISO Satisfaction with financial situation of household (NV_Q50)
0 MA01 MA-01 Tanger-Tetouan-Al Hoceima 6.508333
1 MA02 MA-02 L'Oriental 6.262500
2 MA03 MA-03 Fes-Meknes 6.766667
3 MA04 MA-04 Rabat-Sale-Kenitra 6.141176
4 MA05 MA-05 Beni Mellal-Khenifra 5.975000
5 MA06 MA-06 Casablanca-Settat 6.080769
6 MA07 MA-07 Marrakech-Safi 6.033333
7 MA08 MA-08 Draa-Tafilalet 6.340000
8 MA09 MA-09 Souss-Massa 6.110000
9 MA10 MA-10 Guelmim-Oued Noun 6.200000
10 MA11 MA-11 Laayoune-Sakia El Hamra (EH-partial) 6.850000
11 MA12 MA-12 Dakhla-Oued Ed-Dahab (EH) 5.400000
In [118]:
# updating the chromaplot_df 
chromaplot_df = chromaplot_df.merge(aggregated_data_FoH, how='left', on='ID_list')
chromaplot_df = chromaplot_df.merge(aggregated_data_SFHS, how='left', on='ID_list')
chromaplot_df.rename(columns={
    'Feeling of happiness (NV_Q46)_reversed_x': 'Feeling of happiness (NV_Q46)_reversed',
    'Feeling of happiness (NV_Q46)_reversed_y': 'mean_FoH',
    'Satisfaction with financial situation of household (NV_Q50)_x':'Satisfaction with financial situation of household (NV_Q50)',
    'Satisfaction with financial situation of household (NV_Q50)_y':'mean_SFSH'
}, 
inplace=True)
chromaplot_df
# re-ordering the placement of the columns 
reorder=['ID_list','regions_name','N_REGION_ISO','Feeling of happiness (LV_Q46)','Feeling of happiness (NV_Q46)','Feeling of happiness (NV_Q46)_reversed','mean_FoH','Satisfaction with financial situation of household (NV_Q50)','mean_SFSH']
chromaplot_df = chromaplot_df[reorder]
chromaplot_df
Out[118]:
ID_list regions_name N_REGION_ISO Feeling of happiness (LV_Q46) Feeling of happiness (NV_Q46) Feeling of happiness (NV_Q46)_reversed mean_FoH Satisfaction with financial situation of household (NV_Q50) mean_SFSH
0 MA09 Souss-Massa MA-09 Souss-Massa Quite happy 2.0 3 2.9400 6.0 6.1100
1 MA09 Souss-Massa MA-09 Souss-Massa Not at all happy 4.0 1 2.9400 2.0 6.1100
2 MA09 Souss-Massa MA-09 Souss-Massa Not very happy 3.0 2 2.9400 3.0 6.1100
3 MA09 Souss-Massa MA-09 Souss-Massa Quite happy 2.0 3 2.9400 6.0 6.1100
4 MA09 Souss-Massa MA-09 Souss-Massa Not very happy 3.0 2 2.9400 4.0 6.1100
... ... ... ... ... ... ... ... ... ...
1195 MA02 L'Oriental MA-02 L'Oriental Very happy 1.0 4 3.1375 6.0 6.2625
1196 MA02 L'Oriental MA-02 L'Oriental Quite happy 2.0 3 3.1375 6.0 6.2625
1197 MA02 L'Oriental MA-02 L'Oriental Quite happy 2.0 3 3.1375 3.0 6.2625
1198 MA02 L'Oriental MA-02 L'Oriental Quite happy 2.0 3 3.1375 3.0 6.2625
1199 MA02 L'Oriental MA-02 L'Oriental Quite happy 2.0 3 3.1375 7.0 6.2625

1200 rows × 9 columns

In [119]:
# grouping the values by ID_list
chromaplot_df.groupby('ID_list')[['regions_name','N_REGION_ISO','mean_FoH','mean_SFSH']].value_counts().reset_index()
Out[119]:
ID_list regions_name N_REGION_ISO mean_FoH mean_SFSH count
0 MA01 Tanger-Tetouan-Al MA-01 Tanger-Tetouan-Al Hoceima 2.941667 6.508333 120
1 MA02 L'Oriental MA-02 L'Oriental 3.137500 6.262500 80
2 MA03 Fes-Meknes MA-03 Fes-Meknes 3.020000 6.766667 150
3 MA04 Rabat-Sale-Kenitra MA-04 Rabat-Sale-Kenitra 2.911765 6.141176 170
4 MA05 Beni MA-05 Beni Mellal-Khenifra 2.812500 5.975000 80
5 MA06 Casablanca-Settat MA-06 Casablanca-Settat 2.934615 6.080769 260
6 MA07 Marrakech-Safi MA-07 Marrakech-Safi 2.893333 6.033333 150
7 MA08 Draa-Tafilalet MA-08 Draa-Tafilalet 2.980000 6.340000 50
8 MA09 Souss-Massa MA-09 Souss-Massa 2.940000 6.110000 100
9 MA10 Guelmim-Oued MA-10 Guelmim-Oued Noun 2.900000 6.200000 10
10 MA11 Laayoune-Sakia MA-11 Laayoune-Sakia El Hamra (EH-partial) 2.800000 6.850000 20
11 MA12 Dakhla-Oued MA-12 Dakhla-Oued Ed-Dahab (EH) 3.000000 5.400000 10

Mean Feeling of happiness (reversed) for every region¶

In [120]:
#creating choropleth plots
fig = px.choropleth_mapbox(
    chromaplot_df,
    geojson=morocco_data,
    locations='ID_list',           # Unique region IDs in your DataFrame
    featureidkey="properties.id",  # Matches IDs in GeoJSON
    color='mean_FoH',  # Column to visualize
    hover_name='N_REGION_ISO',  # Column to display region name
    hover_data={
        'N_REGION_ISO' : True
    },   
    mapbox_style="carto-positron", # Base map style
    zoom=4,                        # Zoom level
    center={"lat": 31.7917, "lon": -7.0926},  # Center on Morocco
    color_continuous_scale="rdbu",  # Color scale for data visualization
    title="Average Feeling of Happiness in Morocco", # Map title
    range_color=[0, 4]
)
fig.update_layout(
    margin={"r":0,"t":30,"l":0,"b":0}  # Removes excess margins
)
fig.show()
In [121]:
#pio.write_html(fig, file='plot.html', auto_open=True)  # Save and open the plot in a browser
In [122]:
# showing the rating of the regions based on the Mean Feeling of happiness (reversed) for every region for every region
chromaplot_df.groupby('ID_list')[['N_REGION_ISO','mean_FoH','mean_SFSH']].value_counts().reset_index().sort_values(by='mean_FoH', ascending=False)
Out[122]:
ID_list N_REGION_ISO mean_FoH mean_SFSH count
1 MA02 MA-02 L'Oriental 3.137500 6.262500 80
2 MA03 MA-03 Fes-Meknes 3.020000 6.766667 150
11 MA12 MA-12 Dakhla-Oued Ed-Dahab (EH) 3.000000 5.400000 10
7 MA08 MA-08 Draa-Tafilalet 2.980000 6.340000 50
0 MA01 MA-01 Tanger-Tetouan-Al Hoceima 2.941667 6.508333 120
8 MA09 MA-09 Souss-Massa 2.940000 6.110000 100
5 MA06 MA-06 Casablanca-Settat 2.934615 6.080769 260
3 MA04 MA-04 Rabat-Sale-Kenitra 2.911765 6.141176 170
9 MA10 MA-10 Guelmim-Oued Noun 2.900000 6.200000 10
6 MA07 MA-07 Marrakech-Safi 2.893333 6.033333 150
4 MA05 MA-05 Beni Mellal-Khenifra 2.812500 5.975000 80
10 MA11 MA-11 Laayoune-Sakia El Hamra (EH-partial) 2.800000 6.850000 20

showing the rating of the regions based on mean of Satisfaction with financial situation of household for every region¶

In [123]:
#creating choropleth plots
fig = px.choropleth_mapbox(
    chromaplot_df,
    geojson=morocco_data,
    locations='ID_list',           # Unique region IDs in your DataFrame
    featureidkey="properties.id",  # Matches IDs in GeoJSON
    color='mean_SFSH',  # Column to visualize
    hover_name='N_REGION_ISO',  # Column to display region name
    hover_data={
        'N_REGION_ISO' : True,
        'mean_FoH': True
    },   
    mapbox_style="carto-positron", # Base map style
    zoom=4,                        # Zoom level
    center={"lat": 31.7917, "lon": -7.0926},  # Center on Morocco
    color_continuous_scale="deep",  # Color scale for data visualization
    title="Average Satisfaction with financial situation of household in Morocco",# Map title
    range_color=[0,10]
    )
fig.update_layout(
    margin={"r":0,"t":30,"l":0,"b":0}  # Removes excess margins
)
fig.show()
In [124]:
#pio.write_html(fig, file='plot.html', auto_open=True)  # Save and open the plot in a browser
In [125]:
# showing the rating of the regions based on the Mean of Satisfaction with financial situation of household for every region 
chromaplot_df.groupby('ID_list')[['N_REGION_ISO','mean_FoH','mean_SFSH']].value_counts().reset_index().sort_values(by='mean_SFSH', ascending=False)
Out[125]:
ID_list N_REGION_ISO mean_FoH mean_SFSH count
10 MA11 MA-11 Laayoune-Sakia El Hamra (EH-partial) 2.800000 6.850000 20
2 MA03 MA-03 Fes-Meknes 3.020000 6.766667 150
0 MA01 MA-01 Tanger-Tetouan-Al Hoceima 2.941667 6.508333 120
7 MA08 MA-08 Draa-Tafilalet 2.980000 6.340000 50
1 MA02 MA-02 L'Oriental 3.137500 6.262500 80
9 MA10 MA-10 Guelmim-Oued Noun 2.900000 6.200000 10
3 MA04 MA-04 Rabat-Sale-Kenitra 2.911765 6.141176 170
8 MA09 MA-09 Souss-Massa 2.940000 6.110000 100
5 MA06 MA-06 Casablanca-Settat 2.934615 6.080769 260
6 MA07 MA-07 Marrakech-Safi 2.893333 6.033333 150
4 MA05 MA-05 Beni Mellal-Khenifra 2.812500 5.975000 80
11 MA12 MA-12 Dakhla-Oued Ed-Dahab (EH) 3.000000 5.400000 10

Regional Differences in the Relationship Between Financial Satisfaction and Happiness¶

Based on the choropleth map, we observe that the relationship between financial satisfaction and happiness varies across different regions of Morocco. In some areas, such as major cities like Casablanca and Rabat, we see a stronger connection, where higher financial satisfaction aligns with greater levels of happiness. This could be because these urban centers offer better job opportunities, improved infrastructure, and access to resources that support a higher standard of living.

On the other hand, regions like the Atlas Mountains or rural areas in the southern provinces show weaker or less consistent patterns. In these areas, despite financial satisfaction being lower, happiness levels do not always follow the same trend. Factors such as limited economic opportunities, cultural differences, or access to fewer resources might explain these inconsistencies.

These differences show that the connection between financial satisfaction and happiness can change depending on where people live. Understanding these regional factors can help us better understand why happiness and financial satisfaction are linked in some areas but not in others.